package cn.tedu.myboot24.controller;


import cn.tedu.myboot24.entity.User;
import cn.tedu.myboot24.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;
    @RequestMapping("/check")
    public int check(User user){
        User u=mapper.check(user.getUsername());
        if (u!=null){
            return 2;
        }
        return 1;
    }
    @RequestMapping("/reg")
    public int reg(User user){
        User u=mapper.check(user.getUsername());
        if (u!=null){
            return 1;
        }
        mapper.insert(user);
        return 1;
    }
}
